<script setup>
import {
  onMounted,
  ref,
  reactive,
  getCurrentInstance,
  onActivated,
  watch,
  nextTick
} from 'vue'
import {
  login,
  getInitParam,
  sessionLogList,
  sessionLogDetail
} from '../../../service/api'
import { addTokenToUrl } from '../../../utils/token'
import DigitalPeople from '../components/DigitalPeople.vue'
import ChatBox from '../components/ChatBox.vue'
import Audios from '../components/Audios.vue'
import Worker from '../../../utils/worker.js?worker'
import { jumpHttp, isMobile } from '../../../utils/host'
import defaultIcon from '../../../assets/img/dp-s.png'
import dayjs from 'dayjs'

import MarkdownIt from 'markdown-it'
import hljs from 'highlight.js'
import 'highlight.js/styles/github.css'
const { appContext } = getCurrentInstance()
const proxy = appContext.config.globalProperties
const md = new MarkdownIt({
  highlight: function (str, lang) {
    if (lang && hljs.getLanguage(lang)) {
      try {
        return (
          '<pre class="hljs"><code>' +
          hljs.highlight(lang, str, true).value +
          '</code></pre>'
        )
      } catch (__) {}
    }

    return (
      '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>'
    )
  }
})

const loaded = ref(false)
const digitPeopleRef = ref()
const starRef = ref()
const innerRef = ref()
const voiceRef = ref()
const chatBoxRef = ref()
const sessionId = ref()
const config = reactive({
  data: {}
})

const supportWebGL = ref(window.supportWebGL)

if (!supportWebGL.value) {
  loaded.value = true
}

// 数字人加载进度条
const progress = ref(0)
const onProgress = (e) => {
  progress.value = e
  innerRef.value.style.width = progress.value * 1.5 + 'px'
  starRef.value.style.left = progress.value * 1.5 - 10 + 'px'
}

// 数字人做对应的动作
const doAction = (action) => {
  console.log('调用模型动作', action)
  if (digitPeopleRef.value) {
    digitPeopleRef.value.animationCallback(action)
  }
}

// 播放声音
const playVoice = (voice) => {
  if (voiceRef.value) {
    voiceRef.value.voiceCallback(voice)
  }
}

// 语音或mp3结束
const voiceEnd = () => {
  chatBoxRef.value.voiceEnd()
}

// 点击任务身体
const onClickBody = () => {
  // console.log('点击模型')
  chatBoxRef.value.clickBodyVoiceAndAnimate()
}

// 设置静音
const muted = ref(true)
const toggleMuted = () => {
  muted.value = !muted.value
  voiceRef.value.toogleMuted(muted.value)
}

// 发送问题
const send = (t) => {
  chatBoxRef.value.send(t)
}

// 常用应用
const showAllApp = ref(false)
const apps = ref([])
const go = (item) => {
  if (!item.agentType) {
    proxy.$toast('未获取到agent类型，请检查配置')
    return
  }
  if (item.agentType === 'jump') {
    item.link = !isMobile() ? item.pcLink : item.link
    const url =
      item.appendToken === 0
        ? item.link
        : addTokenToUrl(
            item.link,
            item.putTokenName || 'token',
            item.gainTokenName || 'token'
          )
    jumpHttp(url)
  } else if (item.agentType === 'action') {
    send({
      type: '2',
      data: {
        name: item.content
      }
    })
  }
}

watch(showAllApp, (newValue) => {
  if (newValue === true) {
    const state = {
      title: '',
      url: window.location.href
    }
    window.history.pushState(state, state.title, state.url)
  }
})

// 方言设置
const showLanPop = ref(false)
const canChooseLan = ref(false)
const lans = [
  {
    text: '中文普通话',
    value: 'zwpth'
  },
  // {
  //   text: "中英自由说",
  //   value: "zyzys",
  // },
  // {
  //   text: "湖北话",
  //   value: "hbh",
  // },
  // {
  //   text: "四川话",
  //   value: "sch",
  // },
  // {
  //   text: "粤语（简体）",
  //   value: "yyjt",
  // },
  // {
  //   text: "山西话",
  //   value: "sxh1",
  // },
  {
    text: '湖南话',
    value: 'hnh2'
  },
  {
    text: '河南话',
    value: 'hnh1'
  }
  // {
  //   text: "陕西话",
  //   value: "sxh2",
  // },
  // {
  //   text: "东北话",
  //   value: "dbh",
  // },
  // {
  //   text: "天津话",
  //   value: "tjh",
  // },
  // {
  //   text: "甘肃话",
  //   value: "gsh",
  // },
  // {
  //   text: "贵州话",
  //   value: "gzh",
  // },
  // {
  //   text: "云南话",
  //   value: "ynh",
  // },
  // {
  //   text: "江西话",
  //   value: "jxh",
  // },
  // {
  //   text: "广西话",
  //   value: "gxh",
  // },
  // {
  //   text: "宁夏话",
  //   value: "nxh",
  // },
  // {
  //   text: "山东话",
  //   value: "sdh",
  // },
  // {
  //   text: "苏州话",
  //   value: "szh",
  // },
  // {
  //   text: "浙江话",
  //   value: "zjh",
  // },
  // {
  //   text: "上海话",
  //   value: "shh",
  // },
  // {
  //   text: "维吾尔语",
  //   value: "wwey",
  // },
  // {
  //   text: "闽南语",
  //   value: "mny",
  // },
  // {
  //   text: "粤语（繁体）",
  //   value: "yyft",
  // },
]
const getLanIndex = (value) => {
  let ret = ''
  lans.forEach((item, index) => {
    if (item.value === value) {
      ret = index
    }
  })
  return ret
}
const localLanIndex = getLanIndex(window.localStorage.getItem('lanText')) || 0
const lan = ref(lans[localLanIndex].value)
const clickedLan = ref(lans[localLanIndex].value)
const clickLan = (item) => {
  clickedLan.value = item.value
}
const chooseLan = () => {
  lan.value = clickedLan.value
  window.localStorage.setItem('lanText', clickedLan.value)
  let t
  lans.forEach((item) => {
    if (item.value === clickedLan.value) {
      t = item.text
    }
  })
  proxy.$toast(`您选择了${t}`)
  showLanPop.value = false
}

const modelLogo = ref()
const showLoading = ref(false)
const loadingImg = ref()

// 校园问答
const tagsRef = ref()
const tagsRefPop = ref()
const initialHotKnowledgeData = ref([])
const currentList = ref([])
const handleClick = (item) => {
  showAllKnowledge.value = false
  send({
    type: '1',
    data: {
      name: item.name
    }
  })
}
const changeType = (index) => {
  initialHotKnowledgeData.value.forEach((item) => {
    item.active = false
  })
  initialHotKnowledgeData.value[index].active = true
  currentList.value = initialHotKnowledgeData.value[index].knowledgeList
}
let needInitEvent = true
const handleMoreKnowledge = () => {
  showAllKnowledge.value = true
  if (needInitEvent) {
    nextTick(() => {
      tagsRefPop.value.addEventListener('wheel', (e) => {
        e.preventDefault()
        const step = 20
        if (e.deltaY < 0) {
          tagsRefPop.value.scrollLeft -= step
        } else {
          tagsRefPop.value.scrollLeft += step
        }
      })
      needInitEvent = false
    })
  }
}
const showAllKnowledge = ref(false)

// 登录
const loginApp = () => {
  login()
    .then((res) => {
      window.access_token = res.access_token
      getInitParam()
        .then((res) => {
          // 是否自动跳转
          if (isMobile() && res.autoAdaptHost) {
            window.location.replace(`./index.html${window.location.search}`)
          }
          apps.value = res.chatSubappList
          showLoading.value = true
          loadingImg.value = res.loadingAvatar || defaultIcon // 加载loading页面图标
          res.openVoice = 0 // 暂时设置为0（进来默认没有声音，不使用后台配置参数）
          config.data = res
          sessionId.value = res.sessionId // 会话id
          proxy.$config = res
          document.title = res.serviceName
          modelLogo.value = res.robotJacket // 模型上衣

          getSessionList()

          nextTick(() => {
            voiceRef.value.toogleMuted(muted.value)
          })

          res.hotKnowledgeArray.forEach((item, index) => {
            if (index === 0) {
              item.active = true
              currentList.value = item.knowledgeList.slice(0, 3)
            } else {
              item.active = false
            }
            initialHotKnowledgeData.value.push(item)
          })

          tagsRef.value.addEventListener('wheel', (e) => {
            e.preventDefault()
            const step = 20
            if (e.deltaY < 0) {
              tagsRef.value.scrollLeft -= step
            } else {
              tagsRef.value.scrollLeft += step
            }
          })

          // 屏幕适配
          window.onresize = () => {
            screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
          }
          screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
        })
        .catch((err) => {
          proxy.$toast(err)
        })
    })
    .catch((err) => {
      proxy.$toast(err)
    })
}

// 屏幕适配
const screen = ref()
const container = ref()
const getScale = (w = 1440, h = 813) => {
  const ww = document.body.clientWidth / w
  const wh = (document.body.clientHeight - 48) / h
  return ww < wh ? ww : wh
}

const worker = new Worker()
worker.onmessage = (e) => {
  if (e.data === 'refresh') {
    login().then((res) => {
      window.access_token = res.access_token
    })
  }
}

// 历史记录
const allHistory = []
const historyMore = ref(false)
const historyList = ref([])
const getSessionList = () => {
  sessionLogList({
    sessionId: sessionId.value
  }).then((res) => {
    res.sessionLogList.forEach((item) => {
      item.active = false
      item.time = dayjs(item.createTime).format('YYYY.MM.DD')
      if (item.content) {
        allHistory.push(item)
      }
    })
    if (allHistory.length > 10) {
      historyMore.value = true
    }
    historyList.value = allHistory.slice(0, 10)
  })
}
const clickHistory = (item) => {
  historyList.value.forEach((m) => {
    m.active = false
  })
  item.active = true
  getHistoryDetail(item.sessionId)
}
const getHistoryDetail = (itemSessionId) => {
  chatBoxRef.value.messages = []
  chatBoxRef.value.stopVoiceAndAnimate()
  sessionLogDetail(itemSessionId, true)
    .then((res) => {
      sessionId.value = itemSessionId
      if (res.total == 0) {
        const obj = {
          showInfo: true,
          isHistory: true,
          type: 'Bot',
          message: '当前问题没有回答'
        }
        chatBoxRef.value.messages.push(obj)
        return
      }
      const messages = []
      const QAList = res.records[0].qaList
      QAList.forEach((item) => {
        const obj = {
          showInfo: true,
          isHistory: true,
          isTextEnd: true,
          type: '',
          content: '',
          opsStatus: item.evaluate + '',
          uuid: item.uuid
        }
        if (item.type === 2) {
          obj.type = 'Bot'
        } else if (item.type === 1) {
          obj.type = 'User'
        }
        obj.message = item.content
          ? md.render(item.content).replaceAll('&lt;br&gt;', '<br />')
          : '当前问题没有回答'
        messages.push(obj)
      })
      chatBoxRef.value.showMessages(messages)
    })
    .catch((err) => {
      console.log(`output->err`, err)
      proxy.$toast('err', err)
    })
}
const showMoreHis = () => {
  historyMore.value = false
  historyList.value = allHistory
}

onMounted(() => {
  loginApp()
})

onActivated(() => {
  document.title = config.data.serviceName || '\u200E'
})
</script>
<template>
  <Audios v-if="sessionId" ref="voiceRef" @voice-end="voiceEnd" />
  <div class="page-index" v-show="loaded">
    <div class="nav">
      <span>{{ config.data.nickname || config.data.serviceName }}</span>
    </div>
    <div class="content" ref="container">
      <div class="wrap" ref="screen">
        <div class="left">
          <div id="ops">
            <span
              class="voice"
              :class="{ muted: muted }"
              @click="toggleMuted"
            />
            <span
              class="language"
              v-if="canChooseLan"
              @click.stop="showLanPop = true"
            />
          </div>
          <div id="digit" v-if="sessionId && supportWebGL">
            <DigitalPeople
              ref="digitPeopleRef"
              :model-logo="modelLogo"
              @on-progress="onProgress"
              @click-body="onClickBody"
              @is-loaded="loaded = true"
            />
          </div>
          <div id="chat">
            <ChatBox
              ref="chatBoxRef"
              :muted="muted"
              :session-id="sessionId"
              :lan="lan"
              v-if="loaded && sessionId"
              @do-action="doAction"
              @play-voice="playVoice"
            />
          </div>
        </div>
        <div class="right">
          <div class="panel panel1">
            <div class="header">
              <img class="l" src="../../../assets/img/ph1.png" />
              <div class="r" v-if="initialHotKnowledgeData.length">
                <div class="more" @click="handleMoreKnowledge">查看更多</div>
              </div>
            </div>
            <div class="c">
              <div class="type">
                <div class="tags" ref="tagsRef">
                  <span
                    v-for="(item, index) in initialHotKnowledgeData"
                    :key="index"
                    class="tag"
                    :class="{ act: item.active }"
                    @click="changeType(index)"
                    >{{ item.chatDynamicName }}</span
                  >
                </div>
              </div>
              <div class="lists">
                <div
                  class="ww"
                  v-for="(item, index) in currentList.slice(0, 3)"
                  :key="index"
                >
                  <div class="item" @click="handleClick(item)">
                    <span class="c oneline">{{ item.name }}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="panel panel2">
            <div class="header">
              <img class="l" src="../../../assets/img/ph2.png" />
              <div class="r" v-if="apps.length > 6">
                <div class="more" @click="showAllApp = true">查看更多</div>
              </div>
            </div>
            <div class="c">
              <div
                class="app"
                v-for="(item, index) in apps.slice(0, 6)"
                :key="index"
                @click="go(item)"
              >
                <img :src="item.icon || defaultIcon" alt="" />
                <span class="oneline">{{ item.name }}</span>
              </div>
            </div>
          </div>
          <div class="panel panel3">
            <div class="header">
              <img class="l" src="../../../assets/img/ph3.png" />
              <div class="r">
                <img src="../../../assets/img/small.png" alt="" />
              </div>
            </div>
            <div class="c">
              <div
                class="history"
                :class="{ active: item.active }"
                v-for="(item, index) in historyList"
                :key="index"
                @click="clickHistory(item)"
              >
                <span class="content">{{ item.content }}</span>
                <span class="time">{{ item.time }}</span>
              </div>
              <div v-if="historyMore" class="historyMore" @click="showMoreHis">
                查看更多
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="loading" v-show="!loaded">
    <div class="logo">
      <img v-if="showLoading" :src="loadingImg" />
    </div>
    <div class="ai">
      <img src="../../../assets/img/AI.png" />
      <div class="loader loader-8" />
    </div>
    <div class="wraper">
      <div class="inner" ref="innerRef" />
      <img class="icon" ref="starRef" src="../../../assets/img/small.png" />
    </div>
  </div>
  <van-popup
    id="lanpop"
    :show="showLanPop"
    closeable
    @click-overlay="showLanPop = false"
    @click-close-icon="showLanPop = false"
    teleport="body"
  >
    <div class="form">
      <div class="tags">
        <div
          class="tag"
          :class="{ active: item.value === clickedLan }"
          v-for="(item, index) in lans"
          :key="index"
          @click="clickLan(item)"
        >
          {{ item.text }}
        </div>
      </div>
    </div>
    <div class="btn" @click="chooseLan">确定</div>
  </van-popup>
  <van-popup
    id="apppop"
    :show="showAllApp"
    closeable
    @click-overlay="showAllApp = false"
    @click-close-icon="showAllApp = false"
    teleport="body"
  >
    <div class="apps">
      <div class="header">
        <img src="../../../assets/img/ph2.png" />
      </div>
      <div class="w">
        <div
          class="app"
          v-for="(item, index) in apps"
          :key="index"
          @click="go(item)"
        >
          <img :src="item.icon || defaultIcon" alt="" />
          <span class="oneline">{{ item.name }}</span>
        </div>
      </div>
    </div>
  </van-popup>
  <van-popup
    id="knowledgepop"
    :show="showAllKnowledge"
    closeable
    @click-overlay="showAllKnowledge = false"
    @click-close-icon="showAllKnowledge = false"
    teleport="body"
  >
    <div class="knowledges">
      <div class="header">
        <img src="../../../assets/img/ph1.png" />
      </div>
      <div class="w">
        <div class="type">
          <div class="tags" ref="tagsRefPop">
            <span
              v-for="(item, index) in initialHotKnowledgeData"
              :key="index"
              class="tag"
              :class="{ act: item.active }"
              @click="changeType(index)"
              >{{ item.chatDynamicName }}</span
            >
          </div>
        </div>
        <div class="lists">
          <div
            class="c oneline"
            v-for="(item, index) in currentList"
            :key="index"
            @click="handleClick(item)"
          >
            {{ item.name }}
          </div>
        </div>
      </div>
    </div>
  </van-popup>
</template>

<style lang="less">
.page-index {
  background-color: #eff2f9;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  height: 100%;
  font-size: 12px;
  display: flex;
  flex-direction: column;

  .nav {
    height: 48px;
    padding: 12px 48px;
    font-size: 16px;
    color: #0b9efc;
    line-height: 1;
    font-weight: 600;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background-color: white;
  }

  .content {
    flex: 1;
    overflow: hidden;
    position: relative;

    .wrap {
      position: absolute;
      /* prettier-ignore */
      width: 1440Px;
      /* prettier-ignore */
      height: 804Px;
      left: 50%;
      top: 50%;
      transform-origin: top left;
      display: flex;
      flex-direction: row;
      /* prettier-ignore */
      padding: 24px 32px;

      .left {
        position: relative;
        flex: 1;
        display: flex;
        align-items: center;
        margin-right: 24px;

        #ops {
          position: absolute;
          top: 16px;
          right: 0;
          display: flex;
          align-items: center;
          z-index: 66;

          span {
            width: 32px;
            height: 32px;
            cursor: pointer;
          }

          span:last-child {
            margin-right: 12px;
          }

          .voice {
            background-image: url('../../../assets/img/pv1.png');
            background-size: 100% 100%;
            margin-right: 20px;
          }

          .muted {
            background-image: url('../../../assets/img/pv0.png');
            position: relative;
            top: 1px;
          }

          .language {
            background-image: url('../../../assets/img/pl.png');
            background-size: 100% 100%;
            position: relative;
            top: 1px;
          }
        }

        #digit {
          width: 280px;
          height: 756px;
        }

        #chat {
          height: 100%;
          position: relative;
          flex: 1;
        }
      }

      .right {
        width: 332px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;

        .panel {
          border-radius: 8px;
          overflow: hidden;
          display: flex;
          flex-direction: column;

          .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-left: 12px;
            background: linear-gradient(90deg, #f0f9ff 0%, #d5e6fd 100%);
            .l {
              width: 83px;
              height: 20px;
              height: 35px;
              padding: 6px;
            }
            .r {
              margin-right: 12px;
              img {
                width: 39.4px;
                height: 35px;
              }
              .more {
                cursor: pointer;
                border-radius: 10px;
                width: 67px;
                height: 20px;
                line-height: 20px;
                border: 1px solid #2978e8;
                text-align: center;
                color: #2978e8;
              }
            }
          }

          .c {
            background-color: white;
            flex: 1;
          }
        }

        .panel1 {
          height: 180px;

          .c {
            height: 100%;
            padding: 12px;

            .type {
              display: flex;
              align-items: center;
              color: #666;
              position: relative;

              .tags {
                flex: 1;
                overflow-x: scroll;
                display: flex;
                align-items: center;
                flex-wrap: nowrap;
                position: relative;
                cursor: pointer;
                height: 20px;
                line-height: 20px;

                .tag {
                  padding: 0 18px;
                  word-break: keep-all;
                  white-space: nowrap;
                  margin-right: 8px;
                  border-radius: 10px;
                  color: #546275;
                  background-color: #eef5fc;
                  position: relative;
                  font-size: 10px;
                }

                .act {
                  color: #546275;
                  background-color: rgba(10, 46, 238, 0.1);
                }

                .tag:last-child {
                  margin-right: 0;
                }
              }

              .tags:hover::-webkit-scrollbar {
                width: 0;
                height: 0;
              }
            }

            .lists {
              width: 100%;
              color: #546275;
              font-size: 12px;
              margin-top: 5px;

              .ww {
                display: flex;
                align-items: center;
                padding: 4px;

                .item {
                  flex: 1;
                  display: flex;
                  flex-direction: row;
                  align-items: center;
                  justify-content: space-between;
                  overflow: hidden;
                  cursor: pointer;

                  .c {
                    padding: 5px;
                    position: relative;
                    flex: 1;
                  }
                }
              }
            }
          }
        }

        .panel2 {
          width: 100%;
          height: 205px;
          margin-top: 16px;

          .c {
            padding: 12px 20px 0;

            .app {
              width: 60px;
              height: 68px;
              display: inline-flex;
              align-items: center;
              justify-content: center;
              flex-direction: column;
              cursor: pointer;
              margin-right: 56px;
              margin-bottom: 10px;

              img {
                width: 38px;
                margin-bottom: 12px;
              }

              span {
                text-align: center;
                width: 100%;
              }
            }

            .app:nth-child(3n) {
              margin-right: 0;
            }
          }
        }

        .panel3 {
          height: 339px;
          margin-top: 16px;
          color: #546275;
          font-size: 12px;

          .c {
            padding: 2px 8px;
            overflow: auto;

            .history {
              padding: 0 12px;
              height: 27px;
              line-height: 27px;
              cursor: pointer;
              border-radius: 15px;
              overflow: hidden;
              position: relative;

              .content {
                display: block;
                word-break: keep-all;
                overflow: hidden;
              }

              .time {
                position: absolute;
                width: 85px;
                padding-left: 30px;
                font-size: 10px;
                top: 0;
                right: 0;
                background: linear-gradient(
                  to right,
                  rgba(255, 255, 255, 0.1) 0,
                  rgba(255, 255, 255, 0.8) 15%,
                  rgba(255, 255, 255, 1) 30%
                );
              }
            }

            .history.active {
              background-color: #edf4fc;

              .time {
                background: linear-gradient(
                  to right,
                  rgba(237, 244, 252, 0.1) 0,
                  rgba(237, 244, 252, 0.8) 15%,
                  rgba(237, 244, 252, 1) 30%
                );
              }
            }

            .historyMore {
              width: 140px;
              line-height: 24px;
              text-align: center;
              border-radius: 12px;
              border: 1px solid #2978e8;
              margin: 0 auto;
              cursor: pointer;
              color: #2978e8;
              font-size: 10px;
              margin-top: 4px;
            }
          }
        }
      }
    }
  }
}

.loading {
  width: 150px;
  height: 85px;
  box-sizing: content-box;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  .logo {
    height: 40px;
    overflow: hidden;
    margin-bottom: 10px;

    img {
      display: block;
      width: 40px;
      height: auto;
      margin: 0 auto;
    }
  }

  .ai {
    display: flex;
    justify-content: center;
    align-items: center;

    img {
      width: 72px;
      height: 15px;
      margin-right: 10px;
    }

    .loader {
      width: 15px;
      height: 15px;
      border-radius: 50%;
      display: inline-block;
      position: relative;
      vertical-align: middle;
      font-size: 0;
    }

    .loader,
    .loader:before,
    .loader:after {
      animation: 1s infinite ease-in-out;
    }

    .loader:before,
    .loader:after {
      width: 15px;
      height: 15px;
      border-radius: 50%;
      position: absolute;
      top: 0;
      left: 0;
    }

    .loader-8:before,
    .loader-8:after {
      content: '';
      transform: scale(0);
      animation: loader8 1.5s infinite ease-in-out;
    }

    .loader-8:before {
      background-color: #5baef9;
    }

    .loader-8:after {
      background-color: #8bc8ff;
    }

    .loader-8:after {
      animation-delay: 0.75s;
    }

    @keyframes loader8 {
      0% {
        transform: translateX(-100%) scale(0);
      }

      50% {
        transform: translateX(0%) scale(1);
      }

      100% {
        transform: translateX(100%) scale(0);
      }
    }
  }

  .wraper {
    width: 150px;
    height: 10px;
    background-color: #e2f1fc;
    border-radius: 10px;
    position: absolute;
    bottom: 0;
    left: 0;

    .inner {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      height: 10px;
      width: 0;
      background: linear-gradient(90deg, #b6e9fc 0%, #79b9fa 100%);
      border-radius: 5px;
      z-index: 1;
    }

    .icon {
      width: 20px;
      height: 20px;
      display: block;
      position: absolute;
      left: -2px;
      top: -5px;
      z-index: 2;
      // animation: rotate 2s linear infinite;
    }
  }
}
</style>
